<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>部门管理</title>
    <script type="text/javascript">
      Ext.onReady(function(){
        var accountId=<%=params[:accountId]%>
        var editAccountForm = new Ext.form.FormPanel({
          width:500,
          labelAlign: 'top',
          url:'/account/update',
          buttonAlign:'center',
          autoHeight:true,
          bodyStyle: 'padding:5px',
          labelWidth:100,
          frame: true,
          reader:new Ext.data.JsonReader({
          },[
            {name:'id'},
            {name:'username'},
            {name:'password'}
          ]
        ),
          items:[{
              xtype:'hidden',
              name:'id',
              value:''
            },{
              layout:'column',
              items:[{
                  columnWidth:.5,
                  layout:'form',
                  items:[{
                      xtype:'textfield',
                      fieldLabel: '账号',
                      name: 'username',
                      allowBlank:false,
                      anchor:'90%'

                    }]
                },{
                  columnWidth:.5,
                  layout:'form',
                  items:[{
                      xtype:'textfield',
                      fieldLabel: '密码',
                      name: 'password',
                      anchor:'90%'
                    }]
                }]
            }],
          buttons:[{
              text:'确定',
              handler: function(){
                if (editAccountForm.form.isValid()) {
                  editAccountForm.form.submit({
                    method: 'post',
                    waitMsg: '正在更新账号...',
                    success: function(result, response){
                      if (response.result.info == "success") {
                        editAccountWin.destroy();
                      }
                      else {
                        Ext.MessageBox.alert('消息', response.result.info);
                      }
                    },
                    failure: function(result, response){
                      Ext.MessageBox.alert('提示', result.responseText);
                    }
                  });
                }
                else {
                  Ext.MessageBox.alert('错误提示', '请按要求填写必输选项.');
                }
              }
            },{
              text:'取消',
              handler:function(){
                editAccountWin.destroy();
              }
            }]
        });
        editAccountForm.form.load({
          url: '/account/edit?accountId=' + accountId,
          waitMsg: '正在载入数据...',
          success: function(form, action){
          },
          failure: function(form, action){
            Ext.MessageBox.alert('提示信息', '信息加载失败');
          }
        });
        editAccountForm.render('editAccountForm');
      })
    </script>
  </head>
  <body>
    <div id="editAccountForm"></div>
  </body>
</html>
